one.analysis = function(assignments) {
  df_delegate_survey = subset(assignments, Iteration==ii) %>%
    merge(subset(df_delegate_raw_survey, select=-c(Citizen,Firm,Prop.Citizen,Prop.Firm)))
  df_delegate_pooled = merge(subset(df_delegate_raw_pooled, select=-c(Citizen,Firm,Prop.Citizen,Prop.Firm)), subset(df_delegate_survey, select=c(ID,treat,Citizen,Firm,Prop.Citizen,Prop.Firm)), by='ID')
  df_delegate_caucus = merge(subset(df_delegate_raw_caucus, select=-c(Citizen,Firm,Prop.Citizen,Prop.Firm)), subset(df_delegate_survey, select=c(ID,treat,Citizen,Firm,Prop.Citizen,Prop.Firm)), by='ID')
  df_delegate_query = merge(subset(df_delegate_raw_query, select=-c(Citizen,Firm,Prop.Citizen,Prop.Firm)), subset(df_delegate_survey, select=c(ID,treat,Citizen,Firm,Prop.Citizen,Prop.Firm)), by='ID')
  df_delegate_floor = merge(subset(df_delegate_raw_floor, select=-c(Citizen,Firm,Prop.Citizen,Prop.Firm)), subset(df_delegate_survey, select=c(ID,treat,Citizen,Firm,Prop.Citizen,Prop.Firm)), by='ID')
  
  mutate.lm = function(result) {
    fit = get(result)
    mutate(tidy(fit), Result=result, N=nobs(fit), k=fit$rank, SSR=sum(fit$residuals^2))
  }
  
  fig4a = lm(Missing ~ Citizen, data=subset(df_delegate_survey, Firm==0))
  fig4a = mutate.lm('fig4a')
  fig4b = lm(Missing ~ Firm, data=subset(df_delegate_survey, Citizen==0))
  fig4b = mutate.lm('fig4b')
  
  tab2col1 = lm(Q1 ~ Citizen + Firm, data=df_delegate_survey)
  tab2col1 = mutate.lm('tab2col1')
  tab2col2 = lm(Q1 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_delegate_survey)
  tab2col2 = mutate.lm('tab2col2')
  tab2col2inter = lm(Q1 ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=df_delegate_survey)
  tab2col2inter = mutate.lm('tab2col2inter')
  tab2col3 = lm(Q1 ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=df_delegate_survey)
  tab2col3 = mutate.lm('tab2col3')
  tab2col5 = lm(Q1 ~ Citizen + Firm, data=subset(df_delegate_survey, CentNom<0.5))
  tab2col5 = mutate.lm('tab2col5')
  tab2col6 = lm(Q1 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=subset(df_delegate_survey, CentNom<0.5))
  tab2col6 = mutate.lm('tab2col6')
  tab2col7 = lm(Q1 ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=subset(df_delegate_survey, CentNom<0.5))
  tab2col7 = mutate.lm('tab2col7')
  
  tab2col1livestock = lm(Livestock ~ Citizen + Firm, data=df_delegate_survey)
  tab2col1livestock = mutate.lm('tab2col1livestock')
  tab2col2livestock = lm(Livestock ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_delegate_survey)
  tab2col2livestock = mutate.lm('tab2col2livestock')
  tab2col2livestockinter = lm(Livestock ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=df_delegate_survey)
  tab2col2livestockinter = mutate.lm('tab2col2livestockinter')
  tab2col3livestock = lm(Livestock ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=df_delegate_survey)
  tab2col3livestock = mutate.lm('tab2col3livestock')
  tab2col6livestock = lm(Livestock ~ Citizen + Firm + FullTime + CentNom + Competitive, data=subset(df_delegate_survey, CentNom<0.5))
  tab2col6livestock = mutate.lm('tab2col6livestock')
  
  tab2col1cultivation = lm(Cultivation ~ Citizen + Firm, data=df_delegate_survey)
  tab2col1cultivation = mutate.lm('tab2col1cultivation')
  tab2col2cultivation = lm(Cultivation ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_delegate_survey)
  tab2col2cultivation = mutate.lm('tab2col2cultivation')
  tab2col2cultivationinter = lm(Cultivation ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=df_delegate_survey)
  tab2col2cultivationinter = mutate.lm('tab2col2cultivationinter')
  tab2col3cultivation = lm(Cultivation ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=df_delegate_survey)
  tab2col3cultivation = mutate.lm('tab2col3cultivation')
  tab2col6cultivation = lm(Cultivation ~ Citizen + Firm + FullTime + CentNom + Competitive, data=subset(df_delegate_survey, CentNom<0.5))
  tab2col6cultivation = mutate.lm('tab2col6cultivation')
  
  stacked = rbind(cbind(data.frame(Prepared=df_delegate_survey$Q1, Education=1L), subset(df_delegate_survey, select=c(Citizen,Firm,FullTime,CentNom,Competitive))),
                  cbind(data.frame(Prepared=df_delegate_survey$Livestock, Education=0L), subset(df_delegate_survey, select=c(Citizen,Firm,FullTime,CentNom,Competitive))),
                  cbind(data.frame(Prepared=df_delegate_survey$Cultivation, Education=0L), subset(df_delegate_survey, select=c(Citizen,Firm,FullTime,CentNom,Competitive))))
  placebo.null = lm(Prepared ~ Citizen + Firm + Citizen + Firm + Education + FullTime + CentNom + Competitive, data=stacked)
  placebo.null = mutate.lm('placebo.null')
  placebo = lm(Prepared ~ Citizen + Firm + Citizen*Education + Firm*Education + FullTime + CentNom + Competitive, data=stacked)
  placebo = mutate.lm('placebo')
  
  tab3col1 = lm(Spoke ~ Citizen + Firm, data=df_delegate_pooled)
  tab3col1 = mutate.lm('tab3col1')
  tab3col2 = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_delegate_pooled)
  tab3col2 = mutate.lm('tab3col2')
  tab3col3 = lm(Spoke ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=df_delegate_pooled)
  tab3col3 = mutate.lm('tab3col3')
  tab3col4 = lm(Spoke ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=df_delegate_floor)
  tab3col4 = mutate.lm('tab3col4')
  tab3col5 = lm(Spoke ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=df_delegate_query)
  tab3col5 = mutate.lm('tab3col5')
  tab3col6 = lm(Spoke ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=df_delegate_caucus)
  tab3col6 = mutate.lm('tab3col6')
  
  tab3col3x = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_delegate_pooled)
  tab3col3x = mutate.lm('tab3col3x')
  tab3col3xinter = lm(Spoke ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=df_delegate_pooled)
  tab3col3xinter = mutate.lm('tab3col3xinter')
  tab3col4x = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_delegate_floor)
  tab3col4x = mutate.lm('tab3col4x')
  tab3col4xinter = lm(Spoke ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=df_delegate_floor)
  tab3col4xinter = mutate.lm('tab3col4xinter')
  tab3col5x = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_delegate_query)
  tab3col5x = mutate.lm('tab3col5x')
  tab3col5xinter = lm(Spoke ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=df_delegate_query)
  tab3col5xinter = mutate.lm('tab3col5xinter')
  tab3col6x = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_delegate_caucus)
  tab3col6x = mutate.lm('tab3col6x')
  tab3col6xinter = lm(Spoke ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=df_delegate_caucus)
  tab3col6xinter = mutate.lm('tab3col6xinter')
  
  tab3col7 = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=subset(df_delegate_pooled, CentNom<0.5))
  tab3col7 = mutate.lm('tab3col7')
  tab3col8 = lm(Spoke ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=subset(df_delegate_pooled, CentNom<0.5))
  tab3col8 = mutate.lm('tab3col8')
  
  df_province_pooled = ddply(df_delegate_pooled, 'Province', function(x) {
    df = apply(x[,c('Citizen','Firm','FullTime','CentNom','Competitive')], 2, mean) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(c('Citizen','Firm','FullTime','CentNom','Competitive'))
    apply(x[,match('said_own_province', colnames(x)):match('Spoke', colnames(x))], 2, function(y) {
      as.integer(any(y>0))
    }) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(paste0('any_', colnames(x)[match('said_own_province', colnames(x)):match('Spoke', colnames(x))])) %>%
      cbind(df, .)  
  })
  df_province_caucus = ddply(df_delegate_caucus, 'Province', function(x) {
    df = apply(x[,c('Citizen','Firm','FullTime','CentNom','Competitive')], 2, mean) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(c('Citizen','Firm','FullTime','CentNom','Competitive'))
    apply(x[,match('said_own_province', colnames(x)):match('Spoke', colnames(x))], 2, function(y) {
      as.integer(any(y>0))
    }) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(paste0('any_', colnames(x)[match('said_own_province', colnames(x)):match('Spoke', colnames(x))])) %>%
      cbind(df, .)
  })
  df_province_query = ddply(df_delegate_query, 'Province', function(x) {
    df = apply(x[,c('Citizen','Firm','FullTime','CentNom','Competitive')], 2, mean) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(c('Citizen','Firm','FullTime','CentNom','Competitive'))
    apply(x[,match('said_own_province', colnames(x)):match('Spoke', colnames(x))], 2, function(y) {
      as.integer(any(y>0))
    }) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(paste0('any_', colnames(x)[match('said_own_province', colnames(x)):match('Spoke', colnames(x))])) %>%
      cbind(df, .) 
  })
  df_province_floor = ddply(df_delegate_floor, 'Province', function(x) {
    df = apply(x[,c('Citizen','Firm','FullTime','CentNom','Competitive')], 2, mean) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(c('Citizen','Firm','FullTime','CentNom','Competitive'))
    apply(x[,match('said_Article_02', colnames(x)):match('Spoke', colnames(x))], 2, function(y) {
      as.integer(any(y>0))
    }) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(paste0('any_', colnames(x)[match('said_Article_02', colnames(x)):match('Spoke', colnames(x))])) %>%
      cbind(df, .) 
  })
  df_province_floor$any_said_Article_07 = 0L
  df_province_not_query_texts = apply(df_province_floor[,paste0('any_said_', c('citizens','firms','objectives','vocational','teachers','fees','Article_02','Article_04','Article_07','Article_26','Article_27'))] + 
                                        df_province_caucus[,paste0('any_said_', c('citizens','firms','objectives','vocational','teachers','fees','Article_02','Article_04','Article_07','Article_26','Article_27'))], 2, pmin, 1) %>%
    as.data.frame %>%
    cbind(df_province_pooled[,c('Province','FullTime','CentNom','Competitive','Citizen','Firm')], .)
  
  tab4col1 = lm(any_said_own_province ~ Citizen + Firm, data=df_province_pooled)
  tab4col1 = mutate.lm('tab4col1')
  tab4col2 = lm(any_said_own_province ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_pooled)
  tab4col2 = mutate.lm('tab4col2')
  tab4col3 = lm(any_said_own_province ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_query)
  tab4col3 = mutate.lm('tab4col3')
  tab4col4 = lm(any_said_own_province ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_caucus)
  tab4col4 = mutate.lm('tab4col4')
  
  tab5col1 = lm(any_said_citizens ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_not_query_texts)
  tab5col1 = mutate.lm('tab5col1')
  tab5col2 = lm(any_said_firms ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_not_query_texts)
  tab5col2 = mutate.lm('tab5col2')
  tab5col3 = lm(any_said_objectives ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_not_query_texts)
  tab5col3 = mutate.lm('tab5col3')
  tab5col4 = lm(any_said_vocational ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_not_query_texts)
  tab5col4 = mutate.lm('tab5col4')
  tab5col5 = lm(any_said_teachers ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_not_query_texts)
  tab5col5 = mutate.lm('tab5col5')
  tab5col6 = lm(any_said_fees ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_not_query_texts)
  tab5col6 = mutate.lm('tab5col6')
  
  tab5col3alt = lm(any_said_Article_02 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_not_query_texts)
  tab5col3alt = mutate.lm('tab5col3alt')
  tab5col4alt = lm(any_said_Article_04 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_not_query_texts)
  tab5col4alt = mutate.lm('tab5col4alt')
  tab5col5alt = lm(any_said_Article_07 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_not_query_texts)
  tab5col5alt = mutate.lm('tab5col5alt')
  tab5col6alt = lm(any_said_Article_26 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_not_query_texts)
  tab5col6alt = mutate.lm('tab5col6alt')
  tab5col7alt = lm(any_said_Article_27 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=df_province_not_query_texts)
  tab5col7alt = mutate.lm('tab5col7alt')
  
  rbind(fig4a, fig4b, 
        tab2col1, tab2col2, tab2col3, tab2col5, tab2col6, tab2col7, tab2col2inter,
        tab3col1, tab3col2, tab3col3, tab3col4, tab3col5, tab3col6, tab3col7, tab3col8,
        tab3col3x, tab3col4x, tab3col5x, tab3col6x,
        tab3col3xinter, tab3col4xinter, tab3col5xinter, tab3col6xinter,
        tab4col1, tab4col2, tab4col3, tab4col4,
        tab5col1, tab5col2, tab5col3, tab5col4, tab5col5, tab5col6,
        tab5col3alt, tab5col4alt, tab5col5alt, tab5col6alt, tab5col7alt,
        tab2col1livestock, tab2col2livestock, tab2col3livestock, tab2col6livestock,
        tab2col1cultivation, tab2col2cultivation, tab2col3cultivation, tab2col6cultivation,
        tab2col2livestockinter, tab2col2cultivationinter, placebo, placebo.null) %>%
    mutate(Iteration.Analysis=ii)
}
